#pragma once

#include "BasicType.h"
#include "Character.h"

namespace LightPlayer{

	class LightAbstractRenderer;
	class CharacterList;
	class Shape;
	class Font;


	class GLYPHENTRY{
		uint32					m_GlyphIndex;
		float					m_XAdvance;

	public:
				GLYPHENTRY()																		{init();};
				~GLYPHENTRY()																		{};
		void	init()																				{m_GlyphIndex = 0; m_XAdvance = 0;};
		void	readFromStream(Stream* stream, const TAG& actual_tag, int GlyphBits, int AdvanceBits );

		uint32					getIndex() const													{return m_GlyphIndex;}
		float					getAdvance() const													{return m_XAdvance;}
	};

	struct TEXTRECORD_StateInfo{
		uint16	FontId;
		RGBA	Color;
		float	XOffset;
		float	YOffset;
		int		FontSize;

		TEXTRECORD_StateInfo(){
			FontId = 0; XOffset = 0.0f; YOffset = 0.0f; FontSize = 0;
		}
	};

	class TEXTRECORD{
		uint16					m_FontId;
		Font*					m_pFont;
		CXFORM					m_ColorTransform;
		MATRIX					m_Transform;
		uint16					m_TextHeight;
		array<GLYPHENTRY>		m_Glyphs;
	
	public:
				TEXTRECORD()																							{init();};
				~TEXTRECORD()																							{};
		void	init();
		bool	readFromStream(Stream* stream, const TAG& actual_tag, CharacterList* pCharacterList = NULL, int GlyphBits = 1, int AdvanceBits = 1, TEXTRECORD_StateInfo& StateInfo = TEXTRECORD_StateInfo() );
		void	draw(LightAbstractRenderer* pRenderer, SceneObject* pInstance);
	};

	

	class StaticText : public Character {
		uint16					m_CharacterId;
		RECT					m_TextBounds;
		MATRIX					m_Transformation;
		array<TEXTRECORD>		m_TextRecordList;

	public:

								StaticText()																						{init();};
		virtual					~StaticText()																						{};
				void			init();
				void			readFromStream(Stream* stream, const TAG& actual_tag, CharacterList* pCharacterList = NULL );

		// character interface
		virtual eCharacterType	getType()	const																					{return eStaticTextCharacter;};
		virtual uint16			getCharacterId()	const																			{return m_CharacterId;};
				void			setCharacterId(uint16 characterId)																	{m_CharacterId = characterId;};
		virtual void			draw(LightAbstractRenderer* pRenderer, SceneObject* pInstance);
	};

};